else
this._network = null;
- this._powerProfiles = new imports.ui.status.powerProfiles.Indicator();
this._volume = new imports.ui.status.volume.Indicator();
this._brightness = new imports.ui.status.brightness.Indicator();
this._system = new imports.ui.status.system.Indicator();
if (this._network)
this._indicators.add_child(this._network);
this._indicators.add_child(this._volume);
- this._indicators.add_child(this._powerProfiles);
this.menu.addMenuItem(this._volume.menu);
this.menu.addMenuItem(this._brightness.menu);
if (this._network)
this.menu.addMenuItem(this._network.menu);
- this.menu.addMenuItem(this._powerProfiles.menu);
this.menu.addMenuItem(new PopupMenu.PopupSeparatorMenuItem());
this.menu.addMenuItem(this._system.menu);
- menuLayout.addSizeChild(this._powerProfiles.menu.actor);
menuLayout.addSizeChild(this._system.menu.actor);
}
});
this._thunderbolt = new imports.ui.status.thunderbolt.Indicator();
this._nightLight = new imports.ui.status.nightLight.Indicator();
this._darkMode = new imports.ui.status.darkMode.Indicator();
+ this._powerProfiles = new imports.ui.status.powerProfiles.Indicator();
this._rfkill = new imports.ui.status.rfkill.Indicator();
this._autoRotate = new imports.ui.status.autoRotate.Indicator();
this._unsafeMode = new UnsafeModeIndicator();
this._indicators.add_child(this._location);
this._indicators.add_child(this._nightLight);
this._indicators.add_child(this._darkMode);
+ this._indicators.add_child(this._powerProfiles);
if (this._bluetooth)
this._indicators.add_child(this._bluetooth);
this._indicators.add_child(this._rfkill);
this._addItems(this._location.quickSettingsItems);
if (this._bluetooth)
this._addItems(this._bluetooth.quickSettingsItems);
+ this._addItems(this._powerProfiles.quickSettingsItems);
this._addItems(this._nightLight.quickSettingsItems);
this._addItems(this._darkMode.quickSettingsItems);
this._addItems(this._rfkill.quickSettingsItems);
// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
/* exported Indicator */
-const { Gio, GObject } = imports.gi;
+const {Gio, GObject} = imports.gi;
+
+const {QuickMenuToggle, SystemIndicator} = imports.ui.quickSettings;
-const Main = imports.ui.main;
-const PanelMenu = imports.ui.panelMenu;
const PopupMenu = imports.ui.popupMenu;
-const { loadInterfaceXML } = imports.misc.fileUtils;
+const {loadInterfaceXML} = imports.misc.fileUtils;
const BUS_NAME = 'net.hadess.PowerProfiles';
const OBJECT_PATH = '/net/hadess/PowerProfiles';
const LAST_PROFILE_KEY = 'last-selected-power-profile';
-var Indicator = GObject.registerClass(
-class Indicator extends PanelMenu.SystemIndicator {
+const PowerProfilesToggle = GObject.registerClass(
+class PowerProfilesToggle extends QuickMenuToggle {
_init() {
super._init();
this._profileItems = new Map();
+ this.connect('clicked', () => {
+ this._proxy.ActiveProfile = this.checked
+ ? 'balanced'
+ : global.settings.get_string(LAST_PROFILE_KEY);
+ });
+
this._proxy = new PowerProfilesProxy(Gio.DBus.system, BUS_NAME, OBJECT_PATH,
(proxy, error) => {
if (error) {
this._sync();
});
- this._item = new PopupMenu.PopupSubMenuMenuItem('', true);
-
this._profileSection = new PopupMenu.PopupMenuSection();
- this._item.menu.addMenuItem(this._profileSection);
- this._item.menu.addMenuItem(new PopupMenu.PopupSeparatorMenuItem());
- this._item.menu.addSettingsAction(_('Power Settings'),
- 'gnome-power-panel.desktop');
- this.menu.addMenuItem(this._item);
-
- Main.sessionMode.connect('updated', this._sessionUpdated.bind(this));
- this._sessionUpdated();
- this._sync();
- }
+ this.menu.addMenuItem(this._profileSection);
+ this.menu.setHeader('power-profile-balanced-symbolic', _('Power Profiles'));
- _sessionUpdated() {
- const sensitive = !Main.sessionMode.isLocked && !Main.sessionMode.isGreeter;
- this.menu.setSensitive(sensitive);
+ this._sync();
}
_syncProfiles() {
this._profileItems.set(profile, item);
this._profileSection.addMenuItem(item);
}
+
+ this.menuEnabled = this._profileItems.size > 2;
}
_sync() {
- this._item.visible = this._proxy.g_name_owner !== null;
+ this.visible = this._proxy.g_name_owner !== null;
- if (!this._item.visible)
+ if (!this.visible)
return;
const {ActiveProfile: activeProfile} = this._proxy;
: PopupMenu.Ornament.NONE);
}
- const {label, iconName} = PROFILE_PARAMS[activeProfile];
- this._item.label.text = label;
- this._item.icon.icon_name = iconName;
+ this.set(PROFILE_PARAMS[activeProfile]);
+ this.checked = activeProfile !== 'balanced';
- if (activeProfile !== 'balanced')
+ if (this.checked)
global.settings.set_string(LAST_PROFILE_KEY, activeProfile);
}
});
+
+var Indicator = GObject.registerClass(
+class Indicator extends SystemIndicator {
+ _init() {
+ super._init();
+
+ this.quickSettingsItems.push(new PowerProfilesToggle());
+ }
+});